import {Form,Input,Button,Checkbox,message} from "antd";
import {useStore} from "@/store";
import {useNavigate} from "react-router-dom";
function Login() {
    const {loginStore}=useStore();
    let navigate = useNavigate();
    console.log(loginStore)
    const onFinish = (values) => {
        console.log('Success:', values);
        const {mobile,code}=values;
       loginStore.getToken({
           mobile,
           code
       })
        navigate('/');
        message.success('success-登录成功');


    };

    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };
    return <Form
        name="basic"
        labelCol={{
            span: 8,
        }}
        wrapperCol={{
            span: 16,
        }}
        initialValues={{
            mobile: '17601336017',
            code:'246810'
        }}
        onFinish={onFinish}
        onFinishFailed={onFinishFailed}
        autoComplete="off"
    >
        <Form.Item
            label="Username"
            name="mobile"
            rules={[
                {
                    required: true,
                    message: 'Please input your telphone!',
                },
            ]}
        >
            <Input/>
        </Form.Item>

        <Form.Item
            label="Password"
            name="code"
            rules={[
                {
                    required: true,
                    message: 'Please input your password!',
                },
            ]}
        >
            <Input.Password/>
        </Form.Item>
        <Form.Item
            wrapperCol={{
                offset: 8,
                span: 16,
            }}
        >
            <Button type="primary" htmlType="submit">
                Submit
            </Button>
        </Form.Item>
    </Form>
}
export  default  Login;